﻿////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// <copyright>Copyright 2008-2011 Andreas Huber Doenni</copyright>
// Distributed under the GNU General Public License version 2 (GPLv2).
// See accompanying file License.txt or copy at http://phuse.codeplex.com/license.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

namespace Phuse.Net.Forums
{
    using System;

    /// <summary>The base of all connections.</summary>
    /// <threadsafety static="true" instance="false"/>
    public class Connection : IDisposable
    {
        private IHostInfo host;

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>See <see cref="IDisposable.Dispose"/>.</summary>
        public void Dispose()
        {
            if (this.host != null)
            {
                this.host = null;
                this.Dispose(true);
                GC.SuppressFinalize(this);
            }
        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////

        internal IHostInfo Host
        {
            get { return this.host; }
        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>Initializes a new instance of the <see cref="Connection"/> class.</summary>
        protected Connection(IHostInfo host)
        {
            this.host = host;
        }

        /// <summary>Releases the unmanaged resources used by the <see cref="Connection"/> and optionally releases
        /// the managed resources.</summary>
        protected virtual void Dispose(bool disposing)
        {
        }
    }
}
